package com.example.answer_staff;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import com.gaosai.staff.utils.CommonUtils;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ConfirmActivity extends Activity {

	private String[] enroll;
	private ArrayList<String> confirm_list_key;
	private ArrayList<String> confirm_list_value;
	private View confirm_verify_bt;
	private LinearLayout confirm_Linearlayout_main;
	private LinearLayout confirm_linearlayout_dynamic;
	private String application_list;
	private TextView Confrim_subject;
	private TextView Confirm_startTime;
	private TextView Confirm_endTime;
	private TextView Confirm_Venue;
	private String Subject;
	private int StartTime;
	private int EndTime;
	private String Venue;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.confirm);
		setupView();
		geographicallayout();
	}

	private void setupView() {
		//拿到这些值的目的主要进行循环和往动态布局里边显示值呢
		enroll=getIntent().getStringArrayExtra("enroll");
		confirm_list_key=	getIntent().getStringArrayListExtra("register_list_key");
		confirm_list_value=getIntent().getStringArrayListExtra("register_list_value");
		//此处取得applicaiton——list
		application_list=getIntent().getStringExtra("application_list");
		JsonParse(application_list);
		confirm_verify_bt=findViewById(R.id.activity_confirm_bt);
		Confrim_subject =(TextView)findViewById(R.id.Confrim_subject);
		Confirm_startTime=(TextView)findViewById(R.id.Confirm_startTime);
		Confirm_endTime =(TextView)findViewById(R.id.Confirm_endTime);
		Confirm_Venue=(TextView)findViewById(R.id.Confirm_Venue);
		Confrim_subject.setText(Subject);
		Confirm_startTime.setText(CommonUtils.getDateToStringt(StartTime));
		Confirm_endTime.setText(CommonUtils.getDateToStringt(EndTime));
		Confirm_Venue.setText(Venue);
	}
	private void JsonParse(String json) {
		JSONObject jsonObject=null;
		try {
			jsonObject = new JSONObject( json);
			Subject=jsonObject.getString("subject");
			StartTime=jsonObject.getInt("startTime");
			EndTime=jsonObject.getInt("endTime");
			Venue=jsonObject.getString("venue");
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}
	private void geographicallayout() {
		for(int i=0;i<enroll.length;i++){
			confirm_Linearlayout_main=(LinearLayout)findViewById(R.id.finalconfirm_lineraylayout_main);
			confirm_linearlayout_dynamic=(LinearLayout)LayoutInflater.from(this).inflate(R.layout.verify_textview_dynamic, confirm_Linearlayout_main, false);
			TextView verify_dtextView_dynamic_key = (TextView)confirm_linearlayout_dynamic.findViewById(R.id.verify_dtextView_dynamic_key);
			TextView verify_dtextView_dynamic_value = (TextView)confirm_linearlayout_dynamic.findViewById(R.id.verify_dtextView_dynamic_value);
			verify_dtextView_dynamic_key .setText(confirm_list_key.get(i));
			verify_dtextView_dynamic_value.setText(confirm_list_value.get(i));
			confirm_Linearlayout_main.addView(confirm_linearlayout_dynamic);
		}
	}
}
